package com.ysd.shopcar.processor;

import java.lang.invoke.MethodHandles;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ysd.shopcar.common.BaseProcesser;
import com.ysd.shopcar.common.BaseUtils;
import com.ysd.shopcar.common.JSONResult;
import com.ysd.shopcar.param.in.ChangeProductNumRequestType;
import com.ysd.shopcar.param.out.CarProdcutListResponseType;
import com.ysd.shopcar.service.ShopCarService;

@Component
public class ChangeProductNumProcessor extends BaseProcesser<ChangeProductNumRequestType, ChangeProductNumRequestType>{
	private static final String Title = MethodHandles.lookup().lookupClass().getSimpleName();

	@Autowired
	private ShopCarService shopCarService;

	@Override
	protected void init(ChangeProductNumRequestType request) {
		BaseUtils.putLogTitle(Title);
		BaseUtils.putLogTag("SID", request.getSessionId());
		BaseUtils.putLogTag("UID", request.getUid());
		BaseUtils.putLogTag("PID", request.getPid());
	}

	@Override
	protected void validate(ChangeProductNumRequestType request) {
		BaseUtils.verifyNotNull(request.getUid(), "Uid不允许为空");
		BaseUtils.verifyNotNull(request.getPid(), "Pid不允许为空");
		BaseUtils.verifyNotNull(request.getNums(), "nums不允许为空");
		BaseUtils.verifyNotNull(request.getOperation(), "操作标识位不允许为空");
	}

	@Override
	protected JSONResult<ChangeProductNumRequestType> processing(ChangeProductNumRequestType request) throws Exception {
		return shopCarService.changeProductNumByUIDAndPID(request);
	}

}
